<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="css/base.css" />
    <link rel="stylesheet" href="css/index.css" />
	<script type="text/javascript" src="js/common.js" ></script>
    <script type="text/javascript" charset="utf-8">
      	mui.init();
    </script>
    <style>
    	body{
    		background: url(img/bg.jpg) no-repeat;
    		background-attachment: fixed;
    		background-size: cover;
    	}
    </style>
</head>
<body>
	<div class="login">
		<div class="logo">
			<img src="img/logo.png"/>
		</div>
		<form class="form" id="form">
			<div class="mui-input-row">
		        <label><span class="mui-icon mui-icon mui-icon-person"></span></label>
		    	<input type="text" name="username" class="mui-input-clear" id="username" placeholder="用户名">
		    </div>
		    <div class="mui-input-row">
		        <label><span class="mui-icon mui-icon-help"></span></label>
		        <input type="password" name="password" class="mui-input-password" id="password" placeholder="密码">
		    </div>
		    <div class="mui-button-row">
		    	<input type="button" class="mui-btn mui-btn-block" value="登录" id="login" />
		    </div>
		    <div class="mui-row">
		    	<a href="reg.html" id="reg">还没有账号，现在去注册>></a>
		    </div>
		</form>
	</div>
	<script>
		mui.plusReady(function() {
			
				var loginButton = document.getElementById('login');
				var username = document.getElementById("username");
				var password = document.getElementById("password");
			
			  	loginButton.addEventListener('tap', function(event) {
			  		if(username.value==0){
						mui.toast('请输入用户名！');
						return;
					}
			  		if(password.value==0){
						mui.toast('请输入密码！');
						return;
					}
			  		
                    mui.ajax('http://www.royalplatform.cn/company/app_login.php',{
	                    data:  {
		                   username:username.value,
		                   password:password.value
		               },
	                   dataType:'json',
	                   type:'post',
	                   timeout:'10000',
	                   success:function(data){
	                   	
						 if(data=='1'){  
	                           mui.toast("登录成功");
	                           void myStorage.setItem('username', username.value);
	                           //alert(username.value);
	                           mui.currentWebview.close();
	                           //页面登录处理
	                       }else{
	                       		mui.toast("账号或密码错误！");
	                       }
	                   },
	                   error:function(data){
	                            alert("网络错误！");
	                       }
	               });
	           });
	});	
	</script>
</body>
</html>